   import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

class DialogPage extends StatefulWidget {
  DialogPage({Key key}) : super(key: key);

  @override
  _DialogPageState createState() => _DialogPageState();
}

class _DialogPageState extends State<DialogPage> {

  _alertDialog() async{
    var result = await showDialog(
      context: context,
      builder: (context){
        return AlertDialog(
          title: Text('提示信息！'),
          content: Text('您确定要删除吗？'),
          actions: <Widget>[
            FlatButton(
              child: Text('取消'),
              onPressed: (){
                // print('取消');
                Navigator.pop(context, 'Cancle');
              },
            ),
            FlatButton(
              child: Text('确认'),
              onPressed: (){
                // print('确认');
                Navigator.pop(context, 'Ok');
              },
            )
          ],
        );
      }
    );
    print(result);
  }

  _simpleDialog() async{
    var result = await showDialog(
      context: context,
      builder: (context){
        return SimpleDialog(
          title: Text('选中内容'),
          children: <Widget>[
            SimpleDialogOption(
              child: Text('Option A'),
              onPressed: (){
                print('Option A');
                Navigator.pop(context, 'a');
              },
            ),
            Divider(),
            SimpleDialogOption(
              child: Text('Option B'),
              onPressed: (){
                print('Option B');
                Navigator.pop(context, 'b');
              },
            ),
            Divider(),
            SimpleDialogOption(
              child: Text('Option C'),
              onPressed: (){
                print('Option C');
                Navigator.pop(context, 'c');
              },
            ),
          ],
        );
      }
    );
    print(result);
  }

  _modelBottomDialog() async{
    var result = await showModalBottomSheet(
      context: context,
      builder: (context){
        return Container(
          height: 200,
          child: Column(
            children: <Widget>[
              ListTile(
                title: Text('分享A'),
                onTap: (){
                  Navigator.pop(context, '分享a');
                },
              ),
              Divider(),
              ListTile(
                title: Text('分享B'),
                onTap: (){
                  Navigator.pop(context, '分享b');
                },
              ),
              Divider(),
              ListTile(
                title: Text('分享C'),
                onTap: (){
                  Navigator.pop(context, '分享c');
                },
              ),
            ],
          ),
        );
      }
    );
    print(result);
  }

  _toast() async{
    Fluttertoast.showToast(
      msg: '提示信息',
      toastLength: Toast.LENGTH_SHORT,
      gravity: ToastGravity.BOTTOM,
      timeInSecForIos: 10,
      backgroundColor: Colors.white,
      fontSize: 16.0, 
    );
  }



  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Demo'),
      ),
      body: Padding(
        padding: EdgeInsets.all(20),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            RaisedButton(
              child: Text('alert-alterDialog'),
              onPressed: _alertDialog,
            ),
            SizedBox(height: 20),
            RaisedButton(
              child: Text('alert-simpleDialog'),
              onPressed: _simpleDialog,
            ),
            SizedBox(height: 20),
            RaisedButton(
              child: Text('alert-modelBottomDialog'),
              onPressed: _modelBottomDialog,
            ),
            SizedBox(height: 20),
            RaisedButton(
              child: Text('alert-toast'),
              onPressed: _toast,
            ),
          ],
        ),
      ),
    );
  }
}